﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace SAE_Jam
{
    public static class InputManager
    {
        #region Fields
        private static KeyboardState keyState;
        private static KeyboardState prevkeyState;

        #endregion

        #region Properties
        public static KeyboardState KeyState
        {
            get { return keyState; }
            set { keyState = value; }
        }

        public static KeyboardState PrevkeyState
        {
            get { return prevkeyState; }
            set { prevkeyState = value; }
        }

        #endregion

        #region Methods
        public static void Update()
        {
            prevkeyState = keyState;
            keyState = Keyboard.GetState();
        }

        public static bool KeyPressed(params Keys[] keys)
        {
            foreach (Keys key in keys)
            {
                if (keyState.IsKeyDown(key) && prevkeyState.IsKeyUp(key))
                {
                    return true;
                }
            }
            return false;
        }

        public static bool KeyReleased(params Keys[] keys)
        {
            foreach (Keys key in keys)
            {
                if (keyState.IsKeyUp(key) && prevkeyState.IsKeyDown(key))
                {
                    return true;
                }
            }
            return false;
        }

        public static bool KeyDown(params Keys[] keys)
        {
            foreach (Keys key in keys)
            {
                if (keyState.IsKeyDown(key))
                {
                    return true;
                }
            }
            return false;
        }

        #endregion
    }
}


